package com.jhx.video.widget

import android.app.Dialog
import android.content.Context
import android.view.Gravity
import android.view.View
import android.view.WindowManager
import android.widget.LinearLayout
import android.widget.TextView
import com.jhx.video.R

/**
 *
 * @author Jack 2018-03-11 22:29
 */
class VideoManagerDialog(context: Context) : Dialog(context) {
    var onItemClick: ((view: View?, index: Int) -> Unit)? = null
    private var mTopTxt: TextView? = null
    init {
        setContentView(R.layout.dialog_video_more)
        val layoutParams = window.attributes
        layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT
        layoutParams.gravity = Gravity.BOTTOM
        window.attributes = layoutParams
        val linear = findViewById<LinearLayout>(R.id.view_linear)
        mTopTxt = findViewById(R.id.txt_isTop)
        for(i in 0 until linear.childCount) {
            linear.getChildAt(i).setOnClickListener { view ->
                onItemClick?.invoke(view, i)
                dismiss()
            }
        }
    }

    fun setTopText(text: String?) {
        mTopTxt?.text = "$text"
    }
}